import colors from '@/common/color.js'

/**
 * 工单状态颜色
 * @param {Object} val
 */
export function workOrderStateColor(val) {
	// 待派单
	const waitDelivery = 'wait_delivery';
	// 待接单
	const waitAccept = 'wait_accept'
	// 处理中
	const processing = 'processing'
	// 已暂停
	const suspended = 'suspended'
	// 已终止
	const terminated = 'terminated'
	// 待审核
	const waitAudit = 'wait_audit'
	// 审核未通过
	const notPassAudit = 'not_pass_audit'
	// 待评价
	const waitAppraisal = 'wait_appraisal'
	// 已结束
	const ended = 'ended'

	const red = [waitAccept, terminated, notPassAudit]
	const green = [processing, ]
	const yellow = [suspended, waitAudit]
	const blue = [waitAppraisal]
	const gray = [ended]

	const data = [{
			states: red,
			color: colors.red
		},
		{
			states: green,
			color: colors.green
		}, {
			states: yellow,
			color: colors.yellow
		}, {
			states: blue,
			color: colors.blue
		}, {
			states: gray,
			color: colors.gray
		}
	]

	let rs = data.find((item) => {
		return item.states.includes(val || '')
	})

	if (rs?.color) {
		return {
			color: rs.color
		}
	} else {
		return {
			color: colors.blue
		}
	}

}

/**
 * 工单紧急程度样式
 * @param {*} val 
 */
export function workOrderEmergencyLevelStyle(val) {
	const defaultColor = {
		backgroundColor: colors.white,
		color: '#0F2E4D'
	}
	let color = {
		'1': {
			backgroundColor: colors.red,
			color: colors.white
		},
		'2': {
			backgroundColor: colors.yellow,
			color: colors.white
		},

		'3': {
			backgroundColor: colors.white,
			color: '#0F2E4D'
		},
	}
	if (color[val]) {
		return color[val]
	}
	return defaultColor

}
